<? include ("../init.php") ?>
<? include ("../header.php") ?>
<? include ("../menu.php") ?>
<? include ("submenu.php") ?>
<?php
  function get_product_catname($cat_id){
    $db2 = new DB(DB_NAME, DB_SERVER, DB_USER, DB_PWD);
    $db2->charset(DB_CHARSET);
    $sql = 'SELECT * FROM product_cat WHERE product_cat_id='.$cat_id;
    $line = $db2->queryUniqueObject($sql);
    $db2->close();
    return $line->product_cat_name;
  }
?>
<div id = "body">

<h1><?_l('product')?></h1>

<a href = "form_set.php" class = "add"><img src = "<?=ADMIN?>/images/icon-add.png">&nbsp;&nbsp;&nbsp;<?_l('add-product-set')?></a>

<div class = "clear"></div>

<div class = "page">
<?
  $count = $db->countOfAll('product_set');
  $start = setpage($count);
?>
</div>

<div class = "clear"></div>

<table class ="list">
  <tr>
    <th scope="col"><?_l('set-name')?></th>
    <th scope="col"><?_l('catalogue')?></th>
    <th scope="col" width = "100"><?_l('view-product-in-set')?></th>
    <th scope="col" width = "50"><?_l('edit')?></th>
    <th scope="col" width = "50"><?_l('delete')?></th>
  </tr>
<?
  $rss = $db->query("SELECT * FROM product_set ORDER BY product_set_name LIMIT $start,".PAGE);
  while ($line = $db->fetchNextObject($rss)){
?>
  <tr>
    <td><?=$line->product_set_name?></td>
    <td><?=get_product_catname($line->product_cat_id )?></td>
    <td><a href = "product_list.php?aid=<?=$line->product_set_id?>" class = "btn"><?_l('view')?></a></td>
    <td><a href = "edit_set.php?aid=<?=$line->product_set_id?>" class = "btn"><?_l('edit')?></a></td>
    <td><a href = "del_set.php?aid=<?=$line->product_set_id?>" class = "btn" onClick = "return confirmSubmit('สินค้าที่อยู่ในเซ็ตนี้ทั้งหมด จะถูกลบด้วย คุณต้องการดำเนินการต่อหรือไม่')"><?_l('delete')?></a></td>
  </tr>
<?
  }
?>
</table>

</div>

<style>

</style>

<? include "../footer.php" ?>